﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCNguoiDung.ascx.cs"
    Inherits="Viewer.NguoiDung.UserControls.UCNguoiDung" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="~/NguoiDung/UserControl/AddNguoiDung.ascx" TagName="UcAddNew" TagPrefix="uc" %>
<%@ Register Src="~/NguoiDung/UserControl/DetailNguoiDung.ascx" TagName="UcDetail"
    TagPrefix="uc" %>
<link href="../../resources/css/main.css" rel="stylesheet" type="text/css" />
<ext:XScript ID="XScipt1" runat="server">

    <script type="text/javascript">
        function ConfirmDelete(id) {
            Ext.MessageBox.confirm('Thông báo', 'Bạn có chắc chắn xóa record này ko?<br/>Tất cả dữ liệu liên quan đến người dùng sẽ bị xóa.', function doDel2(btn) {
                if (btn == 'yes') {
                Ext.net.Mask.show();
                    #{DirectMethods}.ShowEditDialog(id,'Delete');
                }
            });
        }
    </script>

</ext:XScript>
<table style="height: 50px; width: 100%; background-color: White;">
    <tr valign="top">
        <td style="padding-top: 10px; width: 100px;">
            <ext:TextField ID="txtName" runat="server" EmptyText="Tên người dùng">
            </ext:TextField>
        </td>
        <td style="padding-top: 10px;" align="left">
            <ext:Button ID="btnSearch" runat="server" Text="Tìm kiếm" Icon="Zoom">
                <Listeners>
                    <Click Handler=" Ext.net.Mask.show();" />
                </Listeners>
                <DirectEvents>
                    <Click OnEvent="btnSearch_Click">
                    </Click>
                </DirectEvents>
            </ext:Button>
        </td>
    </tr>
</table>
<div style="background-color: White;">
    <ext:Panel runat="server" ID="asd" Layout="Fit" MonitorResize="true" BodyStyle="background-color:white;">
        <Content>
            <ext:GridPanel ID="GridPanel1" runat="server" Height="490" AutoExpandColumn="TenDangNhap"
                StripeRows="true" MonitorResize="true" Width="400">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="40" ColumnID="Command" Locked="true">
                            <Commands>
                                <ext:GridCommand>
                                    <Menu>
                                        <Items>
                                            <ext:MenuCommand Text="Xem chi tiết" CommandName="View" Icon="LayoutHeader" />
                                            <ext:MenuCommand Text="Sửa" CommandName="Edit" Icon="ApplicationEdit" />
                                            <ext:MenuCommand Text="Xóa" CommandName="Delete" Icon="Delete" Cls="menuItemTop" />
                                        </Items>
                                    </Menu>
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                        <ext:Column Header="Id" DataIndex="NguoiDungID" Width="200" />
                        <ext:Column Header="Tên đăng nhập" DataIndex="TenDangNhap" Resizable="true" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <Listeners>
                    <Command Handler="if(command=='View'){Ext.net.Mask.show();#{DirectMethods}.ShowEditDialog(record.id,'Detail');} else if(command=='Edit'){Ext.net.Mask.show();#{DirectMethods}.ShowEditDialog(record.id,'Edit');}else if(command=='Delete'){ConfirmDelete(record.id);}" />
                </Listeners>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageIndex="1" PageSize="20"
                        HideRefresh="true">
                    </ext:PagingToolbar>
                </BottomBar>
                <TopBar>
                    <ext:Toolbar ID="Toolbar" runat="server" LabelAlign="Right">
                        <Items>
                            <ext:Button ID="btnAdd" runat="server" Text="Tạo mới" IconAlign="Left" Icon="Add">
                                <Listeners>
                                    <Click Handler=" Ext.net.Mask.show();#{DirectMethods}.ShowEditDialog(0,'AddNew');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store ID="storeHr" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="NguoiDungID">
                                <Fields>
                                    <ext:RecordField Name="NguoiDungID" />
                                    <ext:RecordField Name="TenDangNhap" />
                                    <ext:RecordField Name="MatKhau" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
            </ext:GridPanel>
        </Content>
    </ext:Panel>
</div>
<uc:UcAddNew ID="ucAddNew" runat="server"></uc:UcAddNew>
<uc:UcDetail ID="UcDetail" runat="server"></uc:UcDetail>
